//
//  ClassCourseTimeModel.m
//  HTP
//
//  Created by admin on 15/11/8.
//  Copyright © 2015年 nit. All rights reserved.
//

#import "ClassCourseTimeModel.h"

@implementation ClassCourseTimeModel
-(BOOL)saveBean{
    ClassCourse *classCourse = [ClassCourse findFirstByAttribute:@"cgcId" withValue:self.cgcId];
    if (classCourse == nil) {
        classCourse = [ClassCourse createEntity];
    }
    classCourse.cgcId = self.cgcId;
    classCourse.cgcDate = self.cgcDate;
    classCourse.cgcStartTime = self.cgcStartTime;
    classCourse.cgcStatus = self.cgcStatus;
    classCourse.cgcStopTime = self.cgcStopTime;
    classCourse.nStatus = self.nStatus;
    classCourse.parentId = self.parentId;
    return  [XLCoreDataManager save];
}
+(id)initWithClassCourse:(ClassCourse *)classCourse{
    ClassCourseTimeModel *classC = [[ClassCourseTimeModel alloc] init];
    classC.cgcId = classCourse.cgcId;
    classC.cgcDate = classCourse.cgcDate;
    classC.cgcStartTime = classCourse.cgcStartTime;
    classC.cgcStatus = classCourse.cgcStatus;
    classC.cgcStopTime = classCourse.cgcStopTime;
    classC.nStatus = classCourse.nStatus;
    classC.parentId = classCourse.parentId;
    return classC;
}
+(NSArray *)creatClassCourseTimes:(NSArray *)classCourses{
    NSMutableArray *dataArray = [[NSMutableArray alloc] init];
    [classCourses enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        ClassCourse *classCourse = (ClassCourse *)obj;
        [dataArray addObject:[ClassCourseTimeModel initWithClassCourse:classCourse]];
    }];
    return [NSArray arrayWithArray:dataArray];
}
@end
